package com.mygdx.game.Scenes;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.mygdx.game.Stage.Fight.Fighter;

public class Character_protagonist extends Fighter {
    private Stage stage;
    public Actor presentActor;

    public Character_protagonist(final Stage stage) {
        super("Character/ProtagonistFight");
        this.stage=stage;
        presentActor = new Actor() {
            public void draw(Batch batch, float parentAlpha) {
                Texture t=new Texture("Character/shield.png");
                batch.draw(t,0,400);
            }
        };
    }
    @Override
    public void roundAction() {
        System.out.println("主人公回合结束动作");
        new Thread(){
            @Override
            public void run() {
                for (int i=0;i<3;i++){
                    for (int j=0;j<30;j++){
                        y=y+2;
                        setPosition(x,y);
                        try {
                            sleep(1);
                        }catch (Exception e){

                        }
                    }
                    for (int j=0;j<30;j++){
                        y=y-2;
                        setPosition(x,y);
                        try {
                            sleep(1);
                        }catch (Exception e){

                        }
                    }
                }
            }
        }.start();
    }

    @Override
    public void action1() {
        System.out.println("卡牌-主角动作1");
        new Thread(){
            @Override
            public void run() {
                for (int j=0;j<30;j++){
                    x=x+40;
                    setPosition(x,y);
                    try {
                        sleep(1);
                    }catch (Exception e){

                    }
                }
                try {
                    sleep(500);
                }catch (Exception e){

                }
                for (int j=0;j<300;j++){
                    x=x-4;
                    setPosition(x,y);
                    try {
                        sleep(1);
                    }catch (Exception e){

                    }
                }
            }
        }.start();
    }
    @Override
    public void action2(){
        new Thread(){
            @Override
            public void run(){
                stage.addActor(presentActor);
                try {
                    sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                stage.getRoot().removeActor(presentActor);
            }
        }.start();
    }

    @Override
    public void action3(){
        new Thread(){
            @Override
            public void run(){
                for (int j=0;j<30;j++){
                    x=x+40;
                    setPosition(x,y);
                    try {
                        sleep(1);
                    }catch (Exception e){

                    }
                    try {

                        sleep(500);
                    }catch (Exception e){

                    }
                }

            }
        }.start();
    }

}

